<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>企业添加</title>
</head>
<style>
    *{
        margin: 0;
        padding: 0;
    }
    body{
        background-image: linear-gradient(120deg, #a1c4fd 0%, #c2e9fb 100%);
    }
    h2{
        text-align: center;
        color: #ffffff;
        font-family: "Microsoft Yahei", serif;
        letter-spacing:5px;
        margin-top: 20px;
    }
    form{
        margin: 85px auto auto;
        padding: 10px;
        position: absolute;
        top: 0;left: 0;right: 0;bottom: 0;
        width:500px;
        height: 455px;
        border-radius: 25px;
        background-color:rgba(255, 255, 255, 0.5);
    }
    label{
        letter-spacing:5px;
        font-weight: bold;
    }
    input{
        margin: 2%;
        width: 280px;
    }
    textarea{
        width: 500px;
        height: 80px;
    }
    select.custom-arrow {
        position: relative;
        padding: 8px;
        background-color: #fff;
        border: 1px solid #ccc;
    }
    /* 创建箭头 */
    select.custom-arrow::after {
        content: '';
        position: absolute;
        right: 8px;
        top: calc(50% - 2px);
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 4px solid #000;
        transform: rotate(90deg);
    }
    .container {
        display: flex;
        /* justify-content: space-between;   */
        align-items: center;
    }
    #fileNameInput{
        width: 100px;
    }
    .sub{
        margin-top: 10px;
        text-align: center;
    }
    .sub input{
        width: 20%;
        height: 25px;
        border-radius: 15px;
        border: 1px solid #ccc;
    }
    .sub input:hover{
        background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%);
        border-color: #ccc;
        color: red;
    }
    button{
        float: right;
        margin-right: 10px;
        width: 100px;
        height: 25px;
        border-radius: 15px;
        border: 1px solid #ccc;
    }
    button:hover{
        background-image: linear-gradient(120deg, #d4fc79 0%, #96e6a1 100%);
        border-color: #ccc;
        color: red;
    }
</style>
<body>
<h2>添加企业</h2>
<form action="AddCompanyServlet" method="post">
    <label for="companyName">企业名称：</label>
    <input type="text" id="companyName" name="companyName" required><br>

    <label for="location">企业地址：</label>
    <input type="text" id="location" name="location" required><br>

    <label for="size">企业规模：</label>
    <input type="text" id="size" name="size" required><br>

    <label for="nature">企业性质：</label>
    <input type="text" id="nature" name="nature" required><br>

    <label for="description">企业简介：(不超过1000字)</label>
    <textarea id="description" name="description" rows="4" cols="50"></textarea><br>

    <label for="status">招聘状态：&nbsp;</label>
    <select id="status" class="custom-arrow" name="status">
        <option value="招聘中">招聘中</option>
        <option value="停止招聘">停止招聘</option>
    </select><br>

    <label for="displayOrder">显示排序：</label>
    <input type="number" id="displayOrder" oninput="value=value.replace('-', '')" name="displayOrder" required><br>

    <div class="container">
        <label class="pho" for="fileNameInput">宣传图片：</label>
        <input type="text" id="fileNameInput" placeholder="文件名称" readonly>
        <input type="file" id="fileInput" name="promoImage" style="display: none;">
        <button type="button" onclick="browseFiles()">浏览...</button>
    </div>

    <div class="sub">
        <input type="submit" value="添加企业">
    </div>
    <button type="button" onclick="window.location.href='./index.jsp'">返回首页</button>
</form>
</body>
<script>
    function browseFiles() {
        const fileInput = document.getElementById('fileInput');
        fileInput.click();

        fileInput.onchange = function() {
            let fileNameInput;
            const file = this.files[0];
            if (file) {
                fileNameInput = document.getElementById('fileNameInput');
                fileNameInput.value = file.name; // 更新文本框的值为文件名
            } else {
                fileNameInput = document.getElementById('fileNameInput');
                fileNameInput.value = ''; // 如果没有选择文件，清空文本框
            }
        };
    }
</script>
</html>